package cn.car91.activity;

import android.content.Context;
import android.os.Bundle;
import android.webkit.GeolocationPermissions.Callback;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import cn.car91.R;

import com.lidroid.xutils.view.annotation.ViewInject;

public class DrivingActivity extends BaseActivity {
	
	@ViewInject(R.id.driving_web)
	WebView webView;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		setContentView(R.layout.activity_driving);
		super.onCreate(savedInstanceState);
		
		WebSettings ws = webView.getSettings();
		ws.setJavaScriptEnabled(true);
		ws.setDatabaseEnabled(true);    
        String dir = this.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath(); 

        //启用地理定位  
        ws.setGeolocationEnabled(true);  
        //设置定位的数据库路径  
        ws.setGeolocationDatabasePath(dir);   

        //最重要的方法，一定要设置，这就是出不来的主要原因

        ws.setDomStorageEnabled(true);
        webView.setWebChromeClient(new WebChromeClient(){
			@Override
			public void onGeolocationPermissionsShowPrompt(String origin,
					Callback callback) {
				callback.invoke(origin, true, false);
				super.onGeolocationPermissionsShowPrompt(origin, callback);
			}
        });
        
        webView.loadUrl("http://h.aidaijia.com/");
	}

}
